package lipengfei.botaiframework.mybatisplus.extend.core;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.extension.activerecord.Model;

import cn.hutool.core.util.IdUtil;
import lipengfei.botaiframework.utils.SnowFlakeUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;


/**
 *
 *  @author lipf
 * 实体模型类基础类
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public abstract class BaseEntity <M extends Model<?>> extends Model<M>{
 
	private static final long serialVersionUID = 1L;

	@TableId
	private String id ;

    @TableField(value="version",fill = FieldFill.INSERT)
    private Integer version;
	/***创建人*/
	@TableField(value="created_by",fill = FieldFill.INSERT)
    private String createdBy;
	/*** 创建时间*/
	@TableField(value="created_time",fill = FieldFill.INSERT)
    private Date createdTime;
	/*** 更新人*/
    @TableField(value="updated_by",fill = FieldFill.INSERT_UPDATE)
    private String updatedBy;
    /*** 更新时间*/
    @TableField(value="updated_time",fill = FieldFill.INSERT_UPDATE)
    private Date updatedTime;
    /*** 是否删除*/
    @TableField(value = "del_flag", fill = FieldFill.INSERT)
    @TableLogic
    private String delFlag;

    private String  remarks;

    
    
    /** 请求参数 */
    @TableField(exist = false)
    private Map<String, Object> params;

    public Map<String, Object> getParams()
    {
        if (params == null)
        {
            params = new HashMap<String, Object>();
        }
        return params;
    }
    
    /**
     *  非数据库字段用于时间段查询
     * */
    @TableField(exist = false)
    private  Date createdTimeBg;

    @TableField(exist = false)
    private  Date createdTimeEd;

    public void setParams(String key,Object value){

        if (params == null)
        {
            params = new HashMap<String, Object>();
        }
         params.put(key,value);
    }


}